def merge_arrays(a, k):
    reverse(a, 0, len(a) - 1)
    reverse(a, 0, k - 1)
    reverse(a, k, len(a) - 1)

def reverse(a, start, end):
    while start < end:
        a[start], a[end] = a[end], a[start]
        start += 1
        end -= 1


a = [6, 4, 5, 1, 2, 3]
k = 3
merge_arrays(a, k)
print("合并后的数组:", a)
